package com.schoolgard.entitybean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * Organization entity. 
 * @author luoyegang
 */
@Entity
@Table(name = "ORGANIZATION")
@SequenceGenerator (name="AUTO_ID", sequenceName="AUTO_ID")
public class Organization implements java.io.Serializable {

	private static final long serialVersionUID = 201203101102L;
	private Long id;
	private Regions regions;
	private String name;
	private Short type;
	private Long _parentId;
	private String enable;
	private Long schoolId;
	/*private Set<Device> devices = new HashSet<Device>(0);
	private Set<Users> userses = new HashSet<Users>(0);*/

	// Constructors

	@Column(name = "SCHOOL_ID")
	public Long getSchoolId() {
		return schoolId;
	}

	public void setSchoolId(Long schoolId) {
		this.schoolId = schoolId;
	}

	/** default constructor */
	public Organization() {
	}

	/** minimal constructor */
	public Organization(Long id, Regions regions) {
		this.id = id;
		this.regions = regions;
	}

	// Property accessors
	@Id
	@Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
	@GeneratedValue (strategy=GenerationType.SEQUENCE, generator="AUTO_ID")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "REGIONS_ID", nullable = false)
	public Regions getRegions() {
		return this.regions;
	}

	public void setRegions(Regions regions) {
		this.regions = regions;
	}

	@Column(name = "NAME", length = 64)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "TYPE", precision = 3, scale = 0)
	public Short getType() {
		return this.type;
	}

	public void setType(Short type) {
		this.type = type;
	}

	@Column(name = "PARENT_ID", precision = 22, scale = 0)
	public Long get_parentId() {
		return _parentId;
	}

	public void set_parentId(Long _parentId) {
		this._parentId = _parentId;
	}
	
	@Column(name = "ENABLE", length = 1)
	public String getEnable() {
		return this.enable;
	}

	public void setEnable(String enable) {
		this.enable = enable;
	}

	/*@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "organization")
	public Set<Device> getDevices() {
		return this.devices;
	}

	public void setDevices(Set<Device> devices) {
		this.devices = devices;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "organization")
	public Set<Users> getUserses() {
		return this.userses;
	}

	public void setUserses(Set<Users> userses) {
		this.userses = userses;
	}*/

}